{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 猜猜数字游戏"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入数字：········\n",
      "<class 'int'>\n",
      "请猜一猜：2\n",
      "<class 'int'>\n",
      "恭喜你答对了，你好聪明啊！\n"
     ]
    }
   ],
   "source": [
    "import getpass\n",
    "card = int(getpass.getpass('请输入数字：'))\n",
    "print(type(card))\n",
    "count = 0\n",
    "\n",
    "while True:\n",
    "    if count < 3:\n",
    "        user_guess = int(input('请猜一猜：'))\n",
    "        print(type(user_guess))\n",
    "        if card == user_guess:\n",
    "            print('恭喜你答对了，你好聪明啊！')\n",
    "            break\n",
    "        elif card > user_guess:\n",
    "            print('太小了，往大了猜')\n",
    "    else:\n",
    "        print('哈哈哈哈你怎么那么笨啊猜那么多次都猜不到')\n",
    "        break\n",
    "    count = count +1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 课本练习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入一个字符串hello Winnie,whaat are you doing?\n",
      "{'a': 0, 'e': 0, 'o': 0, 'u': 0, 'f': 0}\n",
      "a is found 3 times\n",
      "e is found 3 times\n",
      "o is found 3 times\n",
      "u is found 1 times\n",
      "f is found 0 times\n"
     ]
    }
   ],
   "source": [
    "shuru = input('请输入一个字符串')\n",
    "found = {}\n",
    "found['a']=0\n",
    "found[\"e\"]=0\n",
    "found[\"o\"]=0\n",
    "found[\"u\"]=0\n",
    "found[\"f\"]=0\n",
    "print(found)\n",
    "\n",
    "\n",
    "for i in shuru:\n",
    "    if i in found:\n",
    "        found[i]+=1\n",
    "        \n",
    "for k in found:\n",
    "    print(k,\"is found\",found[k],\"times\")\n",
    "# print(\"%s is found %s times\" %(k,found[k]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 字典查询练习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "face = {\n",
    "    \"image_id\": \"Dd2xUw9S/7yjr0oDHHSL/Q==\",\n",
    "    \"request_id\": \"1470472868,dacf2ff1-ea45-4842-9c07-6e8418cea78b\",\n",
    "    \"time_used\": 752,\n",
    "    \"faces\": [\n",
    "        {\n",
    "            \"landmark\": {\n",
    "                \"mouth_upper_lip_left_contour2\": {\n",
    "                    \"y\": 185,\n",
    "                    \"x\": 146\n",
    "                },\n",
    "                \"contour_chin\": {\n",
    "                    \"y\": 231,\n",
    "                    \"x\": 137\n",
    "                },\n",
    "                \"right_eye_pupil\": {\n",
    "                    \"y\": 146,\n",
    "                    \"x\": 205\n",
    "                },\n",
    "                \"mouth_upper_lip_bottom\": {\n",
    "                    \"y\": 195,\n",
    "                    \"x\": 159\n",
    "                }\n",
    "            },\n",
    "            \"attributes\": {\n",
    "                \"gender\": {\n",
    "                    \"value\": \"Female\"\n",
    "                },\n",
    "                \"age\": {\n",
    "                    \"value\": 21\n",
    "                },\n",
    "                \"glass\": {\n",
    "                    \"value\": \"None\"\n",
    "                },\n",
    "                \"headpose\": {\n",
    "                    \"yaw_angle\": -26.625063,\n",
    "                    \"pitch_angle\": 12.921974,\n",
    "                    \"roll_angle\": 22.814377\n",
    "                },\n",
    "                \"smile\": {\n",
    "                    \"threshold\": 30.1,\n",
    "                    \"value\": 2.566890001296997\n",
    "                }\n",
    "            },\n",
    "            \"face_rectangle\": {\n",
    "                \"width\": 140,\n",
    "                \"top\": 89,\n",
    "                \"left\": 104,\n",
    "                \"height\": 141\n",
    "            },\n",
    "            \"face_token\": \"ed319e807e039ae669a4d1af0922a0c8\"\n",
    "        }\n",
    "    ],\n",
    "    \"face_num\": 1\n",
    "}\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
